package com.demo.function.dataauth.manager;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Data
public class DataAuthManager implements AutoCloseable {

    private String headerKey;
    private String tableName;
    private String columnName;

    private final static ThreadLocal<DataAuthManager> LOCAL = new ThreadLocal<>();

    private DataAuthManager() {}

    public static DataAuthManager create() {
        DataAuthManager dataAuthManager = new DataAuthManager();
        LOCAL.set(dataAuthManager);
        return dataAuthManager;
    }

    public static DataAuthManager getInstance() {
        return LOCAL.get();
    }

    @Override
    public void close() throws Exception {
        log.info("DataAuthManager.LOCAL关闭");
        LOCAL.remove();
    }
}
